using System;

public class DailyRewardUI : GameUI
{
	public int[] rewards;

	public DailyRewardPrefab[] rewardItems;

	private int rewardDay;

	private void Start()
	{
		DateTime t = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
		if (t > PersistenData.DailyRewardDay)
		{
			Show(PersistenData.DailyRewardProgress + 1);
		}
	}

	public void Show(int day)
	{
		rewardDay = day;
		if (rewardDay >= rewardItems.Length)
		{
			rewardDay = 0;
		}
		for (int i = 0; i < rewardItems.Length; i++)
		{
			rewardItems[i].SetItem(rewards[i], i + 1, rewardDay + 1);
		}
		Show();
	}

	public void Collect()
	{
		PersistenData.Coin += rewards[rewardDay];
		PersistenData.SaveRewardProgress(rewardDay);
		Hide();
	}
}
